import request from '../utils/axios';

// 获取试卷列表（支持分页、搜索、学科筛选）
export function getPaperList(params) {
  return request({
    url: "/paper/papers",
    method: "get",
    params,
  });
}

export function getPaperLists() {
  return request({
    url: "/paper",
    method: "get",

  });
}

// 创建试卷
export function createPaper(data) {
  return request({
    url: "/paper/papers",
    method: "post",
    data,
  });
}

// 更新试卷
export function updatePaper(data) {
  return request({
    url: `/paper/papers`,
    method: "put",
    data,
  });
}

// 删除试卷
export function deletePaper(name) {
  return request({
    url: `/paper/papers/${encodeURIComponent(name)}`,
    method: "delete",
  });
}

// 获取试卷详情（用于答题）
export const getPaperDetail = (name) => {
  return request.get(`/paper/detail/${encodeURIComponent(name)}`)
}


// 提交（保存）试卷答案
export function submitPaperAnswer(data) {
  return request({
    url: `/paper/submit`,
    method: "post",
    data,
  });
}
